package cn.edu.scut.suggestion.phrase;

import java.util.List;

import cn.edu.scut.hsrc.bean.CandidatePhrase;
import cn.edu.scut.hsrc.bean.Doc;
import cn.edu.scut.hsrc.bean.Word;
import cn.edu.scut.hsrc.cluster.semantic.Cluster;
import cn.edu.scut.hsrc.cluster.semantic.PreProcessor;
import cn.edu.scut.hsrc.cluster.semantic.Relation;

/**
 * 包装类，对整个聚类过程进行包装，给外部提供一个统一的接口进行访问
 * @file HSRC.java
 * @author feiyu
 *
 */
/**
 * 将该短语扩展功能引入到查询推荐当中
 * @author tian.yuchen
 */

public class SemanticPhrase{
	
	private final String query;
	private final Doc [] docs;
	
	public SemanticPhrase(String query,Doc [] docs) {
		// TODO Auto-generated constructor stub
		this.query = query;
		this.docs = docs;
	}

	/**
	 * 获取查询推荐词-短语
	 */
	public List<CandidatePhrase> getCandidateSuggPhrase(String query)
	{
		Doc [] docs = this.docs;
		//预处理
		PreProcessor preProcessor = new PreProcessor(this.query, docs);
		preProcessor.doPreProcess();
		docs = preProcessor.getDocs();
		//分析关联关系
		List<Word> aaList=preProcessor.getSegedQuery();
		Relation relation = new Relation(this.query, docs, aaList);
		relation.doRelation();
		
		//对推荐词进行社团发现
	//	try {
		//	DiverseSuggest ds=new DiverseSuggest();
		//	List<CandidateWord>  comunityCanWords=ds.getCanWordComunitied(relation.getCandidateWords(),query);
			
			//获取推荐短语
			Cluster cluster = new Cluster(docs,  relation.getSeqDocs(), relation.getDocWords(), relation.getAllWords(),relation.getCandidateWords(),relation.getDocSimMatrix());
			return cluster.getCandidateSuggPhrase();
		//} catch (RemoteException e) {
			// TODO Auto-generated catch block
	//		e.printStackTrace();
	//		return null;
	//	}

	}
}

